new Vue({
    el: '#main',
    data: () => ({
        details: {},//详细资料
        number: [],//员工数量
        countryname: [],//国家
        linkarr: [],//联系人
        linkindex: '',//编辑时索引
        linkfun: [],//联系类型
        bankarr: [],//银行
        bankindex: '',//银行索引
        banklist: [],//银行
        brancharr: [],//分公司
        branchindex: '',//分公司索引
        evaluatearr: [],//公司风评
        evaluateindex: '',//公司风评索引
        lang: '',//语言
        //联系人弹框
        linkdata: {
            name: '',//姓名
            is_main: '1',//是否主要
            position: '',//职务
            sex: 1,//性别
            linkfunid: '',//联系类型id
            linkval: '',//联系方式值
            linkarr: [],//联系方式
            iseditlianxi: 'a',
            isex: '1',
            lianxi_ids: [],
            biaozhi: '',
        },
        //银行弹框
        bankdata: {
            banks_id: '',//银行id
            bankname: '',//开户行
            account_name: '',//户名
            account_num: '',//账号
            is_main: '1',//是否主要
            biaozhi: '',
        },
        //分公司弹框
        branchdata: {
            name: '',//名称
            lock: false,//是否锁定
            provinces: [],//省份
            city: [],//城市
            town: [],//乡镇
            country_id: '',//国家id
            province_id: '',//省份选择的值
            city_id: '',//城市选择的值
            town_id: '',//乡镇选择的值
            addr: '',//地址
            zipcode: '',//邮编
            works: '1',//员工数量
            regno: '',//营业号
            taxno: ''//税号
        },
        //公司风评弹框
        evaluatedata: {
            comment: '',
            score: '0',
        },
        information: {},//销售资料
        adjustdata: {
            pledge: false,//必须支付定金
            makefirst: false,//允许先配货后结算
            pay_type_ids: [],//允许支付类型
        },//销售资料中调整
        numfail: [],//付款失败次数
        credit4admindata: [],//管理员授权列表
        credit4admin: '',//管理员授权额度
        isdisadble: false,
        islinkman:false,
        isbank:false,
        isbranch:false,
        isevaluate:false,
        buyplan: [],//采购订单产品
        buyplanpage: 1,//采购产品分页
        buylist: [],//采购合同数据
        buylistpage: 1,//采购合同分页
        buyid: '',//点击的合同id
        packdata: [],//合同详情中产品数据
        sale: [],//销售订单产品
        salepage: 1,//销售产品分页
        prodata: [],//销售产品
        buypo: [],//销售订单下合同
        buypopage: 1,//销售合同分页
        saleSize: 10,
        pageSize: 30,
    }),
    mounted(){
        if (this.getQueryString('tab') == 'link') {
            //联系人
            $('.nav-tabs .active').removeClass("active")
            $('.nav-tabs li').eq(1).addClass("active")
            $('.tab-content .active').removeClass("active")
            $('#table-linkman').addClass("active")
            //联系人数据
            this.getdata('link', 'linkarr');
        } else if (this.getQueryString('tab') == 'bank') {
            //银行
            $('.nav-tabs .active').removeClass("active")
            $('.nav-tabs li').eq(2).addClass("active")
            $('.tab-content .active').removeClass("active")
            $('#table-bank').addClass("active")
            //银行账户数据
            this.getdata('bank', 'bankarr');
        } else if (this.getQueryString('tab') == 'branch') {
            //分公司
            $('.nav-tabs .active').removeClass("active")
            $('.nav-tabs li').eq(3).addClass("active")
            $('.tab-content .active').removeClass("active")
            $('#co-branch').addClass("active")
            //分公司数据
            this.getdata('branch', 'brancharr');
        } else if (this.getQueryString('tab') == 'evaluate') {
            //风评
            $('.nav-tabs .active').removeClass("active")
            $('.nav-tabs li').eq(4).addClass("active")
            $('.tab-content .active').removeClass("active")
            $('#co-evaluate').addClass("active")
            //公司风评数据
            this.getdata('evaluate', 'evaluatearr');
        } else {
            this.getdata('detail', 'details');
        }
        //初始化联系人
        $('#linkman_Modal').on('hide.bs.modal', () => {
            $('.modal-body .alert').hide()
            $('.modal-body .alert p').html()
            this.linkdata = this.$options.data().linkdata
            localStorage.removeItem("model");
        })
        //初始化银行
        $('#bank_Modal').on('hide.bs.modal', () => {
            $('.modal-body .alert').hide()
            $('.modal-body .alert p').html()
            this.bankdata = this.$options.data().bankdata
            localStorage.removeItem("model");
        })
        //初始化分公司
        $('#branch_editModal').on('hide.bs.modal', () => {
            $('.modal-body .alert').hide()
            $('.modal-body .alert p').html()
            this.branchdata = this.$options.data().branchdata
            localStorage.removeItem("model");
        });
        //初始化风评
        $('#co_evaluate_Modal').on('hide.bs.modal', () => {
            $('.modal-body .alert').hide()
            $('.modal-body .alert p').html()
            this.evaluatedata = this.$options.data().evaluatedata
            localStorage.removeItem("model");
        });
        //初始化公司调整
        $('#co_sale_settingModal').on('hide.bs.modal', () => {
            $('.modal-body .alert').hide()
            $('.modal-body .alert p').html()
            this.adjustdata = this.$options.data().adjustdata
            this.numfail = []
            this.credit4admindata = []
            this.credit4admin = ''
            localStorage.removeItem("model");
        });
    },
    methods: {
        formatUnit: formatUnit,
        getdata(type, arrdata){
            $('.loding').show();
            $.ajax({
                url: '/admin/customer/companycheck',
                data: {
                    status: type,//状态
                    company_id: $('#company_id').val(),//公司id
                    country_id: $('#country_id').val(),//国家id
                },
                type: 'post',
                success: (data) => {
                    data = JSON.parse(data);
                    if (type == 'link') {
                        //联系人
                        this.linkfun = data.linkfun;//联系类型
                    } else if (type == 'bank') {
                        //银行
                        this.banklist = data.bankdata;//银行
                    } else if (type == 'branch') {
                        //分公司
                        this.countryname = data.countryname;
                        this.number = data.number;
                        this.lang = data.lang;
                    }
                    this[arrdata] = data.data
                    $('.loding').hide();
                }
            })
        },
        //有分页调用
        getdatapage(type, page, pageSize){
            $('.loding').show();
            $.ajax({
                url: '/admin/customer/companycheck',
                data: {
                    company_id: $('#company_id').val(),//公司id
                    status: type,//状态
                    page: this[page],
                    pageSize: this[pageSize],
                },
                type: 'post',
                success: (data) => {
                    data = JSON.parse(data);
                    this[type] = data.data
                    if (type == 'sale') {
                        //销售订单中产品
                        this.prodata = data.prodata;
                    }
                    if (data.size) {
                        this.setPageFun(parseInt(this[page]), data.size, '#pagination_' + type, parseInt(this[pageSize]))
                    }
                    $('.loding').hide();
                }
            })
        },
        setPageFun(pageCurrent, pageSum, dom, pageSize) {
            //数据总条数
            var myPageCount = pageSum;
            //一页显示多少条
            var myPageSize = pageSize;
            //总页数
            var countindex = myPageCount % myPageSize > 0 ? (myPageCount / myPageSize) + 1 : (myPageCount / myPageSize);
            $.jqPaginator(dom, {
                totalPages: parseInt(countindex),
                //最多显示多少页
                visiblePages: 5,
                //默认显示第几页
                currentPage: pageCurrent,
                first: '<li class="first"><a href="javascript:;">' + langcon.page_home + '</a></li>',
                prev: '<li class="prev"><a href="javascript:;"><i class="arrow arrow2"></i>' + langcon.previous_page + '</a></li>',
                next: '<li class="next"><a href="javascript:;">' + langcon.next_page + '<i class="arrow arrow3"></i></a></li>',
                last: '<li class="last"><a href="javascript:;">' + langcon.last_page + '</a></li>',
                page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
                all: '<li class="page"><a href="javascript:;">' + myPageCount + ' / ' + pageCurrent + 'PG , ' + pageSize + ' /PG</a></li>',
                onPageChange: (num, type) => {
                    if (type == "change") {
                        switch (dom) {
                            //采购订单中的产品
                            case '#pagination_buyplan':
                                this.buyplanpage = num
                                this.getdatapage('buyplan', 'buyplanpage', 'pageSize')
                                break;
                            //采购订单中的合同
                            case '#pagination_buylist':
                                this.buylistpage = num
                                this.getdatapage('buylist', 'buylistpage', 'pageSize')
                                break;
                            //销售订单产品
                            case '#pagination_sale':
                                this.salepage = num
                                this.getdatapage('sale', 'salepage', 'saleSize')
                                break;
                            //销售订单合同
                            case '#pagination_buypo':
                                this.buypopage = num
                                this.getdatapage('buypo', 'buypopage', 'pageSize')
                                break;
                        }
                    }
                }
            });
        },
        //返回列表页
        returnlist(){
            location.href = "/admin/customer/customercompany"
        },
        getQueryString(name){
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)return unescape(r[2]);
            return null;
        },
        //添加联系人
        addlinkman(){
            this.linkdata.biaozhi = 'linkmanadd';
        },
        //编辑联系人
        editlinkman(index){
            this.linkdata.name = this.linkarr[index].name;
            this.linkdata.is_main = this.linkarr[index].is_main;
            this.linkdata.position = this.linkarr[index].position;
            this.linkdata.sex = this.linkarr[index].sex;
            this.linkdata.linkarr = this.linkarr[index].linkarr;
            this.linkdata.biaozhi = 'linkmanedit';
            this.linkindex = index;
        },
        //联系人 银行 分公司 公司风评的删除
        deldata(id, index, code){
            var urldel = '';
            if (code == 1) {
                //联系人
                urldel = '?liaisondel&linkid=' + id
            } else if (code == 2) {
                //银行
                urldel = '?bankdel&bankid=' + id
            } else if (code == 3) {
                //分公司
                urldel = '?branchdel&branchid=' + id
            } else if (code == 4) {
                //公司风评
                urldel = '?evaluatedel&evaluateid=' + id
            }
            $.ajax({
                url: '/admin/customer/companycheck' + urldel,
                type: 'post',
                success: (data) => {
                    data = JSON.parse(data)
                    change_mes_type('#headeralert', data.status)
                    $('#headeralert').show()
                    $('#headeralert p').html('*' + data.msg + '<br>')
                    if (data.status == 1) {
                        if (code == 1) {
                            //联系人
                            this.linkarr.splice(index, 1);
                        } else if (code == 2) {
                            //银行
                            this.bankarr.splice(index, 1);
                        } else if (code == 3) {
                            //分公司
                            this.brancharr.splice(index, 1);
                        } else if (code == 4) {
                            //公司风评
                            this.evaluatearr.splice(index, 1);
                        }
                    }
                }
            })
        },
        //添加联系方式
        addlinkmethod(){
            //还有联系方式值和联系类型id
            if (this.linkdata.linkval && this.linkdata.linkfunid) {
                if (this.linkdata.iseditlianxi > 0 && this.linkdata.iseditlianxi != 'a') {
                    //通过点击编辑，添加的联系方式
                    let lanxieditid = this.linkdata.linkarr[this.linkdata.iseditlianxi]['coattr_id'];//联系类型id
                    if (lanxieditid != this.linkdata.linkfunid) {
                        //编辑的联系方式改变了，就需要判断现在重新添加的类型是否存在语列表页面
                        $.each(this.linkdata.linkarr, (key, value) => {
                            if (value.coattr_id == this.linkdata.linkfunid) {
                                change_mes_type('.modal-body .alert', 3)
                                $('.modal-body .alert').show()
                                $('.modal-body .alert p').html('*编辑的联系方式已经存在' + '<br>');
                                this.linkdata.isex = '2';
                            }
                        });
                        //存在联系方式的重置
                        if (this.linkdata.isex == '2') {
                            this.linkdata.isex = '1';
                            return false;
                        }
                        if (this.linkdata.isex == '1') {
                            //编辑时写的是其他的联系方式
                            this.linkdata.linkarr[this.linkdata.iseditlianxi]['linkname'] = $("#sellinkfun").find("option:selected").text();
                            this.linkdata.linkarr[this.linkdata.iseditlianxi]['coattr_id'] = this.linkdata.linkfunid;
                        }
                    }
                    //无论联系类型id是否改变，更新内容
                    this.linkdata.linkarr[this.linkdata.iseditlianxi]['content'] = this.linkdata.linkval;
                } else {
                    //直接添加联系方式
                    this.listlanxitwo();
                    let isexit = this.linkdata.lianxi_ids.findIndex(item => item == this.linkdata.linkfunid);
                    if (isexit >= 0) {
                        //添加时，添加的联系方式类型，存在列表,覆盖操作
                        $.each(this.linkdata.linkarr, (key, value) => {
                            if (value.coattr_id == this.linkdata.linkfunid) {
                                this.linkdata.linkarr[key]['content'] = this.linkdata.linkval;
                            }
                        });
                    } else {
                        //添加
                        this.linkdata.linkarr.push({
                            id: '',//联系方式id
                            linkname: $("#sellinkfun").find("option:selected").text(),
                            coattr_id: this.linkdata.linkfunid,//联系方式类型id
                            content: this.linkdata.linkval,//联系方式
                        })
                    }
                }
                this.linkdata.isex = '1';
                this.linkdata.iseditlianxi = 'a'
                this.linkdata.linkval = '';
                this.linkdata.linkfunid = '';
            } else {
                change_mes_type('.modal-body .alert', 2)
                $('.modal-body .alert').show()
                $('.modal-body .alert p').html('*数据不完整' + '<br>')
            }
        },
        //获取最新的联系类型id
        listlanxitwo(){
            this.linkdata.lianxi_ids = [];
            this.linkdata.linkarr.forEach((element, index) => {
                this.linkdata.lianxi_ids.push(element.coattr_id)
            })
        },
        //编辑联系方式
        editlinkfun(index){
            this.linkdata.linkval = this.linkdata.linkarr[index].content
            if (this.linkdata.linkarr[index].linkname) {
                this.linkdata.linkfunid = this.linkdata.linkarr[index].coattr_id
            } else {
                this.linkdata.linkfunid = '';
            }
            this.linkdata.iseditlianxi = index;
            this.linkdata.isex = '1';
        },
        //删除联系方式
        dellinkitem(index){
            this.linkdata.linkarr.splice(index, 1);
            this.linkdata.iseditlianxi = 'a';
            this.linkdata.isex = '1';
        },
        //保存联系方式
        addlinkdata(){
            this.islinkman = true;
            var linkid = this.linkarr[this.linkindex] ? this.linkarr[this.linkindex].id : '';
            $.ajax({
                url: '/admin/customer/companycheck',
                type: 'post',
                data: {
                    name: this.linkdata.name,
                    is_main: this.linkdata.is_main,
                    position: this.linkdata.position,
                    sex: this.linkdata.sex,
                    linkarr: this.linkdata.linkarr,
                    biaozhi: this.linkdata.biaozhi,
                    isedit: 1,
                    co_id: $('#company_id').val(),
                    linkid: linkid,
                    linkaddedit:''
                },
                success: (data) => {
                    data = JSON.parse(data)
                    if (data.status != 1) {
                        change_mes_type('.modal-body .alert', data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*' + data.msg + '<br>')
                    } else {
                        this.getdata('link', 'linkarr');
                        change_mes_type('#headeralert', data.status)
                        $('#headeralert').show()
                        $('#linkman_Modal').modal('hide')
                        $('#headeralert p').html('*' + data.msg + '<br>')
                    }
                    this.islinkman = false;
                }
            })
        },
        //添加银行账号
        addbank(){
            this.bankdata.biaozhi = 'bankadd';
        },
        //编辑银行账号
        editbank(index){
            this.bankdata.banks_id = this.bankarr[index].banks_id;
            this.bankdata.bankname = this.bankarr[index].bankname;
            this.bankdata.account_name = this.bankarr[index].account_name;
            this.bankdata.account_num = this.bankarr[index].account_num;
            this.bankdata.is_main = this.bankarr[index].is_main;
            this.bankdata.biaozhi = 'bankedit';
            this.bankindex = index;
        },
        //保存银行账号
        addbankdata(){
            this.isbank = true;
            var bankid = this.bankarr[this.bankindex] ? this.bankarr[this.bankindex].id : '';
            $.ajax({
                url: '/admin/customer/companycheck',
                type: 'post',
                data: {
                    banks_id: this.bankdata.banks_id,
                    bankname: this.bankdata.bankname,
                    account_name: this.bankdata.account_name,
                    account_num: this.bankdata.account_num,
                    is_main: this.bankdata.is_main,
                    biaozhi: this.bankdata.biaozhi,
                    isedit: 1,
                    co_id: $('#company_id').val(),
                    bankid: bankid,
                    bankaddedit:''
                },
                success: (data) => {
                    data = JSON.parse(data)
                    if (data.status != 1) {
                        change_mes_type('.modal-body .alert', data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*' + data.msg + '<br>')
                    } else {
                        this.getdata('bank', 'bankarr');
                        change_mes_type('#headeralert', data.status)
                        $('#headeralert').show()
                        $('#bank_Modal').modal('hide')
                        $('#headeralert p').html('*' + data.msg + '<br>')
                    }
                    this.isbank = false;
                }
            })
        },
        //添加分公司
        addbranch(){
            if ($('#country_id').val()) {
                //有公司id
                this.selchangebranchfun('provinces', $('#country_id').val());
                this.branchdata.country_id = $('#country_id').val();
            }
            this.branchdata.biaozhi = 'branchadd';
        },
        //分公司地址的改变
        selchangebranchfun(type, val){
            return new Promise((res, rej) => {
                $.ajax({
                    url: '/admin/api/getprovinces',
                    type: 'post',
                    data: {
                        tables: type,
                        id: val
                    },
                    success: (data) => {
                        data = JSON.parse(data)
                        switch (type) {
                            case 'provinces':
                                this.branchdata.provinces = data
                                this.branchdata.city = []
                                this.branchdata.town = []
                                this.branchdata.province_id = ''
                                this.branchdata.city_id = ''
                                this.branchdata.town_id = ''
                                break;
                            case 'city':
                                this.branchdata.city = data
                                this.branchdata.town = []
                                this.branchdata.city_id = ''
                                this.branchdata.town_id = ''
                                break;
                            case 'town':
                                this.branchdata.town = data
                                this.branchdata.town_id = ''
                                break;
                        }
                        res()
                    }
                })
            })
        },
        //编辑分公司
        editbranch(index){
            this.branchdata.name = this.brancharr[index].name;
            this.branchdata.lock = this.brancharr[index].lock;

            this.branchdata.country_id = this.brancharr[index].country_id;
            var getbreach = async () => {
                await this.selchangebranchfun('provinces', this.brancharr[index].country_id);
                this.branchdata.province_id = this.brancharr[index].province_id;
                await this.selchangebranchfun('city', this.brancharr[index].province_id);
                this.branchdata.city_id = this.brancharr[index].city_id;
                await this.selchangebranchfun('town', this.brancharr[index].city_id)
                this.branchdata.town_id = this.brancharr[index].town_id;
            }
            getbreach()
            this.branchdata.addr = this.brancharr[index].addr;
            this.branchdata.zipcode = this.brancharr[index].zipcode;
            this.branchdata.works = this.brancharr[index].works;
            this.branchdata.regno = this.brancharr[index].regno;
            this.branchdata.taxno = this.brancharr[index].taxno;
            this.branchdata.biaozhi = 'branchedit';
            this.branchindex = index;
        },
        //点击锁定
        lockbut(){
            if (this.branchdata.lock == '1' || this.branchdata.lock == true) {
                this.branchdata.lock = '0';
            } else {
                this.branchdata.lock = '1';
            }
        },
        //保存分公司
        addbranchdata(){
            this.isbranch = true;
            var branchid = this.brancharr[this.branchindex] ? this.brancharr[this.branchindex].id : '';
            $.ajax({
                url: '/admin/customer/companycheck',
                type: 'post',
                data: {
                    name: this.branchdata.name,
                    lock: this.branchdata.lock,
                    country_id: this.branchdata.country_id,
                    province_id: this.branchdata.province_id,
                    city_id: this.branchdata.city_id,
                    town_id: this.branchdata.town_id,
                    addr: this.branchdata.addr,
                    zipcode: this.branchdata.zipcode,
                    regno: this.branchdata.regno,
                    taxno: this.branchdata.taxno,
                    works: this.branchdata.works,
                    biaozhi: this.branchdata.biaozhi,
                    lang: this.lang,
                    isedit: 1,
                    co_id: $('#company_id').val(),
                    id: branchid,
                    branchaddedit:''
                },
                success: (data) => {
                    data = JSON.parse(data)
                    if (data.status != 1) {
                        change_mes_type('.modal-body .alert', data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*' + data.msg + '<br>')
                    } else {
                        this.getdata('branch', 'brancharr');
                        change_mes_type('#headeralert', data.status)
                        $('#headeralert').show()
                        $('#branch_editModal').modal('hide')
                        $('#headeralert p').html('*' + data.msg + '<br>')
                    }
                    this.isbranch = false;
                }
            })
        },
        //添加风评
        addevaluate(){
            this.evaluatedata.biaozhi = 'evaluateadd';
        },
        //编辑风评
        editevaluate(index){
            this.evaluatedata.biaozhi = 'evaluateedit';
            this.evaluateindex = index;
            this.evaluatedata.comment = this.evaluatearr[index].comment;
            this.evaluatedata.score = this.evaluatearr[index].score;
        },
        //保存公司风评
        addevaluatedata(){
            this.isevaluate = true;
            var evaluateid = this.evaluatearr[this.evaluateindex] ? this.evaluatearr[this.evaluateindex].id : '';
            $.ajax({
                url: '/admin/customer/companycheck',
                type: 'post',
                data: {
                    biaozhi: this.evaluatedata.biaozhi,
                    comment: this.evaluatedata.comment,
                    score: this.evaluatedata.score,
                    isedit: 1,
                    co_id: $('#company_id').val(),
                    id: evaluateid,
                    evaluateaddedit:''
                },
                success: (data) => {
                    data = JSON.parse(data)
                    if (data.status != 1) {
                        change_mes_type('.modal-body .alert', data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*' + data.msg + '<br>')
                    } else {
                        this.getdata('evaluate', 'evaluatearr');
                        change_mes_type('#headeralert', data.status)
                        $('#headeralert').show()
                        $('#co_evaluate_Modal').modal('hide')
                        $('#headeralert p').html('*' + data.msg + '<br>')
                    }
                    this.isevaluate = false;
                }
            })
        },
        //公司调整
        getadjust(){
            $.ajax({
                url: '/admin/customer/companyadjust',
                type: 'post',
                data: {
                    company_id: $('#company_id').val(),//公司id
                    adjust: ''
                },
                success: (res) => {
                    data = JSON.parse(res);
                    if (data.adjustdata) {
                        this.adjustdata = data.adjustdata;
                    }
                    this.numfail = data.numfail;//失败次数
                    this.credit4admindata = data.credit4admindata;//管理员额度
                }
            })
        },
        //点击必须支付定金和允许先配货结算
        makefirstpledge(codestatus){
            if (codestatus == 'pledge') {
                if (this.adjustdata.pledge == true) {
                    this.adjustdata.pledge = false;
                } else {
                    this.adjustdata.pledge = true;
                }
            } else if (codestatus == 'makefirst') {
                if (this.adjustdata.makefirst == true) {
                    this.adjustdata.makefirst = false;
                } else {
                    this.adjustdata.makefirst = true;
                }
            }
        },
        //调整的保存
        saveadjust(){
            this.isdisadble = true;
            $.ajax({
                url: '/admin/customer/companyadjust',
                type: 'post',
                data: {
                    company_id: $('#company_id').val(),//公司id
                    adjustsave: '',
                    pledge: this.adjustdata.pledge,
                    makefirst: this.adjustdata.makefirst,
                    pay_type_ids: this.adjustdata.pay_type_ids,
                    delivery_id: this.adjustdata.delivery_id,
                    credit4admin: this.credit4admin
                },
                success: (res) => {
                    data = JSON.parse(res);
                    if (data.status != 1) {
                        change_mes_type('.modal-body .alert', data.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*' + data.msg + '<br>')
                    } else {
                        change_mes_type('#headeralert', data.status)
                        $('#headeralert').show()
                        $('#headeralert p').html('*' + data.msg + '<br>')
                        $('#co_sale_settingModal').modal('hide');
                    }
                    this.getdata('information', 'information');
                    this.isdisadble = false;
                }
            })
        },
        //采购订单合同详情
        buypro(id){
            $.ajax({
                url: '/admin/customer/companycheck',
                type: 'post',
                data: {
                    id,
                    company_id: $('#company_id').val(),//公司id
                    getpro: ''
                },
                success: (res) => {
                    data = JSON.parse(res);
                    this.buyid = id;
                    this.packdata = data;
                }
            })
        }
    }
})
$("#linkman_Modal").on("hidden.bs.modal", function () {
    $(this).removeData("bs.modal");
    $(document).unbind('keydown')
});
$("#bank_Modal").on("hidden.bs.modal", function () {
    $(this).removeData("bs.modal");
    $(document).unbind('keydown')
});
$("#branch_editModal").on("hidden.bs.modal", function () {
    $(this).removeData("bs.modal");
    $(document).unbind('keydown')
});
$("#co_evaluate_Modal").on("hidden.bs.modal", function () {
    $(this).removeData("bs.modal");
    $(document).unbind('keydown')
});